package lambdademo;

import java.util.Comparator;
import java.util.PriorityQueue;
//无返回值无参数
@FunctionalInterface
interface NoParameterNoReturn {
    void test();
}
public class Test {
    public static void main(String[] args) {
        //有返回值无参数类型
      /*  NoParameterReturn noParameterReturn = ()->10;
        System.out.println(noParameterReturn.test());*/

        //有返回值有一个参数类型
      /*  OneParameterReturn oneParameterReturn = a -> a;
        System.out.println(oneParameterReturn.test(10));*/

        //有返回值有多个参数类型
        MoreParameterReturn moreParameterReturn = (x,y) -> x+y;
        System.out.println(moreParameterReturn.test(10,27));
    }

    public static void main3(String[] args) {
       /* NoParameterNoReturn noParameterNoReturn2 =()-> System.out.println("test..");
        NoParameterNoReturn.test();*/
        //一个参数
       /* OneParameterNoReturn oneParameterNoReturn = (x)->{
            System.out.println(x);
        };
        oneParameterNoReturn.test(10);//10*/
        //多个参数
        MoreParameterNoReturn moreParameterNoReturn = (x,y)-> System.out.println(x+y);
        moreParameterNoReturn.test(10,20);

    }
    public static void main2(String[] args) {
        NoParameterNoReturn noParameterNoReturn = new NoParameterNoReturn() {
            @Override
            public void test() {
                System.out.println("test.....");
            }
        };
        noParameterNoReturn.test();
        System.out.println("--------");
        NoParameterNoReturn noParameterNoReturn2 =()-> System.out.println("test..");
        noParameterNoReturn2.test();
    }
    public static void main1(String[] args) {
        PriorityQueue<Integer> priorityQueue = new PriorityQueue<>(new Comparator<Integer>() {
            @Override
            public int compare(Integer o1, Integer o2) {
                return o1-o2;
            }
        });
        PriorityQueue<Integer> priorityQueue12 = new PriorityQueue<>(((o1,o2)->{return o1-o2;}));
    }
}
//无返回值一个参数
@FunctionalInterface
interface OneParameterNoReturn {
    void test(int a);
}

//无返回值多个参数
@FunctionalInterface
interface MoreParameterNoReturn {
    void test(int a,int b);
}



//有返回值无参数
@FunctionalInterface
interface NoParameterReturn {
    int test();
}


//有返回值一个参数
@FunctionalInterface
interface OneParameterReturn {
    int test(int a);
}

//有返回值多参数
@FunctionalInterface
interface MoreParameterReturn {
    int test(int a,int b);
}


